home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / scripts / smorph2.irt < prev    next >
Encoding:
Text File  |  1994-09-03  |  8.1 KB  |  276 lines

  1. #
  2. # A simple example of surface morphing.
  3. #
  4. #                    Gershon Elber, July 1992.
  5. #
  6. # render with raysahde with a unit matrix and the following:
  7. #
  8. # eyep   10 8  6
  9. # lookp  0  0  0
  10. # up     0  0  1
  11. # fov 12
  12. # light 0.8 directional 0 0 1
  13. # light 0.7 directional 0 1 0
  14. # light 0.6 directional 1 0 0
  15.  
  16. save_res = resolution;
  17.  
  18. if ( machine == msdos, resolution = 7, resolution = 10 );
  19. if ( machine == msdos, step = 0.2, step = 0.05 );
  20.  
  21. FloorLvl = -0.72;
  22. FloorXYMin = -1.4;
  23.  
  24. v1 = vector( -16.0, -16.0, FloorLvl );
  25. V2 = vector( -16.0,  16.0, FloorLvl );
  26. v3 = vector(  16.0,  16.0, FloorLvl );
  27. v4 = vector(  16.0, -16.0, FloorLvl );
  28. Floor = poly( list( v1, v2, v3, v4 ), false );
  29. color( Floor, red );
  30. attrib( Floor, "rgb", "244,164,96" );
  31. attrib( Floor, "texture", "wood" );
  32. attrib( Floor, "reflect", 0.3 );
  33.  
  34. Wall1 = poly( list( vector( FloorXYMin,       16.0, FloorLvl ),
  35.             vector( FloorXYMin, FloorXYMin, FloorLvl ),
  36.             vector( FloorXYMin, FloorXYMin, 16.0 ),
  37.             vector( FloorXYMin,       16.0, 16.0 ) ),
  38.           false );
  39. Wall2 = poly( list( vector(       16.0, FloorXYMin, FloorLvl ),
  40.             vector( FloorXYMin, FloorXYMin, FloorLvl ),
  41.             vector( FloorXYMin, FloorXYMin, 16.0 ),
  42.             vector(       16.0, FloorXYMin, 16.0 ) ),
  43.           false );
  44. color( Wall1, white );
  45. attrib( Wall1, "rgb", "255,255,255" );
  46. color( Wall2, white );
  47. attrib( Wall2, "rgb", "255,255,255" );
  48.  
  49. Backgrd = list( Floor, Wall1, Wall2 );
  50.  
  51. #############################################################################
  52. # First Morphing Sequence.                            #
  53. #############################################################################
  54.  
  55. Srf1 = ruledsrf( circle( vector( 0.0, 0.0, FloorLvl + 0.01 ), 1.0 ),
  56.          circle( vector( 0.0, 0.0, FloorLvl + 0.01 ), 0.01 ) );
  57. color( Srf1, yellow );
  58.  
  59. bcross = cbspline( 3,
  60.            list( ctlpt( E3,  0.0,  0.0, -0.71 ),
  61.                  ctlpt( E3,  0.2,  0.0, -0.72 ),
  62.                  ctlpt( E3,  0.25, 0.0, -0.7 ),
  63.                  ctlpt( E3,  0.25, 0.0, -0.1 ),
  64.                  ctlpt( E3,  0.2,  0.0, -0.05 ),
  65.                  ctlpt( E3,  0.15, 0.0,  0.0 ),
  66.                  ctlpt( E3,  0.1,  0.0,  0.6 ),
  67.              ctlpt( E3,  0.11, 0.0,  0.61 ),
  68.              ctlpt( E3,  0.12, 0.0,  0.61 ),
  69.              ctlpt( E3,  0.12, 0.0,  0.65 ),
  70.              ctlpt( E3,  0.09, 0.0,  0.65 ),
  71.              ctlpt( E3,  0.07, 0.0,  0.64 ),
  72.              ctlpt( E3,  0.10, 0.0, -0.05 ),
  73.              ctlpt( E3,  0.21, 0.0, -0.1 ),
  74.              ctlpt( E3,  0.21, 0.0, -0.64 ),
  75.              ctlpt( E3,  0.18, 0.0, -0.67),
  76.              ctlpt( E3,  0.0,  0.0, -0.66 ) ),
  77.            list( KV_OPEN ) );
  78. Srf2 = surfrev( bcross );
  79. free( bcross );
  80. color( Srf2, green );
  81.  
  82. #
  83. # Must make them compatible before doing some morphing.
  84. #
  85. ffcompat( Srf1, Srf2 );
  86.  
  87. #
  88. # Since we would like the animation to look as good as possible we need
  89. # to precompute as much as possible before invoking view to erase old
  90. # drawing and display new one. That is why we precompute isolines.
  91. #
  92. for ( i = 0, step, 1.0,
  93.     view( smorph( Srf1, Srf2, i ), on )
  94. );
  95.  
  96. #############################################################################
  97. # Second Morphing Sequence.                            #
  98. #############################################################################
  99.  
  100. bcross = cbspline( 3,
  101.            list( ctlpt( E3,  0.0,  0.0, -0.71 ),
  102.                  ctlpt( E3,  0.2,  0.0, -0.72 ),
  103.                  ctlpt( E3,  0.25, 0.0, -0.7 ),
  104.                  ctlpt( E3,  0.25, 0.0, -0.1 ),
  105.                  ctlpt( E3,  0.2,  0.0, -0.05 ),
  106.                  ctlpt( E3,  0.15, 0.0,  0.0 ),
  107.                  ctlpt( E3,  0.1,  0.0,  0.6 ),
  108.              ctlpt( E3,  0.11, 0.0,  0.61 ),
  109.              ctlpt( E3,  0.12, 0.0,  0.61 ),
  110.              ctlpt( E3,  0.12, 0.0,  0.65 ),
  111.              ctlpt( E3,  0.09, 0.0,  0.65 ),
  112.              ctlpt( E3,  0.07, 0.0,  0.64 ),
  113.              ctlpt( E3,  0.10, 0.0, -0.05 ),
  114.              ctlpt( E3,  0.21, 0.0, -0.1 ),
  115.              ctlpt( E3,  0.21, 0.0, -0.64 ),
  116.              ctlpt( E3,  0.18, 0.0, -0.67),
  117.              ctlpt( E3,  0.0,  0.0, -0.66 ) ),
  118.            list( KV_OPEN ) );
  119. Srf2 = surfrev( bcross );
  120. free( bcross );
  121. color( Srf2, green );
  122.  
  123. gcross = cbspline( 3,
  124.            list( ctlpt( E3, 0.001, 0.0, 0.02 ),
  125.                ctlpt( E3, 0.2,   0.0, 0.02 ),
  126.              ctlpt( E3, 0.22,  0.0, 0. ),
  127.              ctlpt( E3, 0.22,  0.0, 0.03 ),
  128.              ctlpt( E3, 0.03,  0.0, 0.03 ),
  129.              ctlpt( E3, 0.03,  0.0, 0.07 ),
  130.              ctlpt( E3, 0.04,  0.0, 0.3 ),
  131.              ctlpt( E3, 0.3,   0.0, 0.3 ),
  132.              ctlpt( E3, 0.4,   0.0, 0.4 ),
  133.              ctlpt( E3, 0.3,   0.0, 0.7 ),
  134.              ctlpt( E3, 0.28,  0.0, 0.7 ),
  135.              ctlpt( E3, 0.37,  0.0, 0.42 ),
  136.              ctlpt( E3, 0.31,  0.0, 0.32 ),
  137.              ctlpt( E3, 0.001, 0.0, 0.32 ) ),
  138.         list( KV_OPEN ) );
  139. Srf3 = surfrev( gcross * trans( vector( 0.0, 0.0, -0.45 ) ) *
  140.              scale( vector( 1.6, 1.6, 1.6 ) ) );
  141. free( gcross );
  142. color( Srf3, cyan );
  143.  
  144. #
  145. # Must make them compatible before doing some morphing.
  146. #
  147. ffcompat( Srf2, Srf3 );
  148.  
  149. for ( i = 0, step, 1.0,
  150.     view( smorph( Srf2, Srf3, i ), true )
  151. );
  152.  
  153. #############################################################################
  154. # Third Morphing Sequence.                            #
  155. #############################################################################
  156.  
  157. gcross = cbspline( 3,
  158.            list( ctlpt( E3, 0.001, 0.0, 0.02 ),
  159.                ctlpt( E3, 0.2,   0.0, 0.02 ),
  160.              ctlpt( E3, 0.22,  0.0, 0. ),
  161.              ctlpt( E3, 0.22,  0.0, 0.03 ),
  162.              ctlpt( E3, 0.03,  0.0, 0.03 ),
  163.              ctlpt( E3, 0.03,  0.0, 0.07 ),
  164.              ctlpt( E3, 0.04,  0.0, 0.3 ),
  165.              ctlpt( E3, 0.3,   0.0, 0.3 ),
  166.              ctlpt( E3, 0.4,   0.0, 0.4 ),
  167.              ctlpt( E3, 0.3,   0.0, 0.7 ),
  168.              ctlpt( E3, 0.28,  0.0, 0.7 ),
  169.              ctlpt( E3, 0.37,  0.0, 0.42 ),
  170.              ctlpt( E3, 0.31,  0.0, 0.32 ),
  171.              ctlpt( E3, 0.001, 0.0, 0.32 ) ),
  172.         list( KV_OPEN ) );
  173. Srf3 = surfrev( gcross * trans( vector( 0.0, 0.0, -0.45 ) ) *
  174.              scale( vector( 1.6, 1.6, 1.6 ) ) );
  175. free( gcross );
  176. color( Srf3, cyan );
  177.  
  178. s45 = sin( pi / 4 );
  179. HelixAux = cbspline( 3,
  180.              list( ctlpt( P3, 1, 1, 0, 0 ),
  181.                ctlpt( P3, s45, s45, s45, 0.2 * s45 ),
  182.                ctlpt( P3, 1, 0, 1, 0.4 ),
  183.                ctlpt( P3, s45, -s45, s45, 0.6 * s45 ),
  184.                ctlpt( P3, 1, -1, 0, 0.8 ),
  185.                ctlpt( P3, s45, -s45, -s45, 1.0 * s45 ),
  186.                ctlpt( P3, 1, 0, -1, 1.2 ),
  187.                ctlpt( P3, s45, s45, -s45, 1.4 * s45 ),
  188.                ctlpt( P3, 1, 1, 0, 1.6 ) ),
  189.              list( 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4 ) );
  190. HelixApx = HelixAux +
  191.        HelixAux * trans( vector( 0.0, 0.0, 1.6 ) ) +
  192.        HelixAux * trans( vector( 0.0, 0.0, 3.2 ) );
  193.  
  194. ScaleCrv = cbezier( list( ctlpt( E2, 0.0, 0.01 ),
  195.               ctlpt( E2, 1.0, 1.0 ) ) );
  196.  
  197. Srf4 = swpsclsrf( circle( vector( 0.0, 0.0, 0.0 ), 0.8 ), HelixApx, ScaleCrv,
  198.          off, 0 ) *
  199.     scale( vector( 0.2, 0.2, 0.2 ) ) *
  200.     trans( vector( 0.0, 0.0, FloorLvl ) );
  201.  
  202. free( HelixAux );
  203. free( HelixApx );
  204. free( ScaleCrv );
  205. color( Srf4, magenta );
  206.  
  207. #
  208. # Must make them compatible before doing some morphing.
  209. #
  210. ffcompat( Srf3, Srf4 );
  211.  
  212. for ( i = 0, step, 1.0,
  213.     view( smorph( Srf3, Srf4, i ), true )
  214. );
  215.  
  216. #############################################################################
  217. # Fourth Morphing Sequence.                            #
  218. #############################################################################
  219.  
  220. s45 = sin( pi / 4 );
  221. HelixAux = cbspline( 3,
  222.              list( ctlpt( P3, 1, 1, 0, 0 ),
  223.                ctlpt( P3, s45, s45, s45, 0.2 * s45 ),
  224.                ctlpt( P3, 1, 0, 1, 0.4 ),
  225.                ctlpt( P3, s45, -s45, s45, 0.6 * s45 ),
  226.                ctlpt( P3, 1, -1, 0, 0.8 ),
  227.                ctlpt( P3, s45, -s45, -s45, 1.0 * s45 ),
  228.                ctlpt( P3, 1, 0, -1, 1.2 ),
  229.                ctlpt( P3, s45, s45, -s45, 1.4 * s45 ),
  230.                ctlpt( P3, 1, 1, 0, 1.6 ) ),
  231.              list( 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4 ) );
  232. HelixApx = HelixAux +
  233.        HelixAux * trans( vector( 0.0, 0.0, 1.6 ) ) +
  234.        HelixAux * trans( vector( 0.0, 0.0, 3.2 ) );
  235.  
  236. ScaleCrv = cbezier( list( ctlpt( E2, 0.0, 0.01 ),
  237.               ctlpt( E2, 1.0, 1.0 ) ) );
  238.  
  239. Srf4 = swpsclsrf( circle( vector( 0.0, 0.0, 0.0 ), 0.8 ), HelixApx, ScaleCrv,
  240.          off, 0 ) *
  241.     scale( vector( 0.2, 0.2, 0.2 ) ) *
  242.     trans( vector( 0.0, 0.0, FloorLvl ) );
  243.  
  244. free( HelixAux );
  245. free( HelixApx );
  246. free( ScaleCrv );
  247. color( Srf4, magenta );
  248.  
  249. Srf1 = ruledsrf( circle( vector( 0.0, 0.0, FloorLvl + 0.01 ), 1.0 ),
  250.          circle( vector( 0.0, 0.0, FloorLvl + 0.01 ), 0.01 ) );
  251. color( Srf1, yellow );
  252.  
  253. #
  254. # Must make them compatible before doing some morphing.
  255. #
  256. ffcompat( Srf4, Srf1 );
  257.  
  258. #
  259. # Since we would like the animation to look as good as possible we need
  260. # to precompute as much as possible before invoking view to erase old
  261. # drawing and display new one. That is why we precompute isolines.
  262. #
  263. for ( i = 0, step, 1.0,
  264.     view( smorph( Srf4, Srf1, i ), true )
  265. );
  266.  
  267. free(Srf1);
  268. free(Srf2);
  269. free(Srf3);
  270. free(Srf4);
  271.  
  272. resolution = save_res;
  273.  
  274.